package dxunderground.winampController.Server.GUI;

import java.awt.BorderLayout;
import java.io.IOException;

import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;

import org.jdom.JDOMException;

import dxunderground.winampController.Common.FilterPanel;
import dxunderground.winampController.Common.GUI;
import dxunderground.winampController.Common.StatusPanel;

@SuppressWarnings("serial")
public class ControlPanel extends JPanel {
	public ControlPanel(ButtonActions buttonActions, GUI gui) throws JDOMException, IOException {
		JPanel loadPanel = new LoadPanel(gui, buttonActions);

		gui.listModel = new DefaultListModel();
		gui.list = new JList(gui.listModel);
		gui.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		gui.list.setLayoutOrientation(JList.VERTICAL);

		JScrollPane listScroller = new JScrollPane(gui.list);

		JPanel filterPanel = new FilterPanel(gui, buttonActions);
		JPanel statusPanel = new StatusPanel(gui, buttonActions);

		JPanel centerPanel = new JPanel(new BorderLayout());
		centerPanel.add(listScroller, BorderLayout.CENTER);
		centerPanel.add(filterPanel, BorderLayout.SOUTH);

		this.setLayout(new BorderLayout());
		this.add(loadPanel, BorderLayout.NORTH);
		this.add(centerPanel, BorderLayout.CENTER);
		this.add(statusPanel, BorderLayout.SOUTH);
	}
}
